#include <iostream>

int const maxn = 1007;
int da[maxn];
bool vis[maxn];
int n, ans;

int main()
{
	std::cin >> n;
	for (int i = 0; i < n; i++) std::cin >> da[i];

	int count = 0, dir = 1, p = 0;
	for (; ; ans++) {
		for (; p >= 0 && p < n; p += dir) {
			if (!vis[p] && count >= da[p]) {
				vis[p] = true;
				count++;
			}
		}
		p -= dir;
		dir = - dir;
		if (count >= n) break;
	}
	std::cout << ans << '\n';
}



